#pragma once
#include <string>
#include <vector>

using std::string;
using std::vector;

vector<string> split(const string& line, char delimiter) {
    vector<string> tokens;
    size_t start = 0;
    size_t end = line.find(delimiter);

    while (end != string::npos) {
        tokens.push_back(line.substr(start, end - start));
        start = end + 1;
        end = line.find(delimiter, start);
    }
    // Adding the last token
    tokens.push_back(line.substr(start, end));

    return tokens;
}

// Example usage
#include <iostream>

int main() {
    string line = "Hello,World,This,is,a,test";
    char delimiter = ',';
    
    vector<string> result = split(line, delimiter);
    
    for (size_t i = 0; i < result.size(); ++i) {
        std::cout << result[i] << std::endl;
    }

    return 0;
}
